package day9;

import java.sql.*;
import java.util.Date;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Jdbc2 {
    public static void main(String[] args) {
        //jdbc
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return;
        }
        String url="jdbc:mysql://localhost:3308/fuyang?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8";
        String user="root";
        String pass="root1234";
        try {
            Connection con = DriverManager.getConnection(url, user, pass);
            System.out.println(con);
            Statement st = con.createStatement();
            //delete
            System.out.println("请输入要删除的用户：");
            long id=new Scanner(System.in).nextLong();
            int r = st.executeUpdate("delete from user where id="+id);
            System.out.println(r+"个用户被删除了。。。");
            st.close();
            con.close();//隐患
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
